xen, vtd: Fix device check for devices behind PCIe-to-PCI bridges
authorGeorge Dunlap <george.dunlap@eu.citrix.com>
Mon, 5 Sep 2011 14:00:46 +0000 (15:00 +0100)
committerGeorge Dunlap <george.dunlap@eu.citrix.com>
Mon, 5 Sep 2011 14:00:46 +0000 (15:00 +0100)
commitba3d7de6ce6f239c2a44ffba6256095101d757dd
tree573252dfc4a09cde5b246da6f9bef07cf732cb86
parent3ec1e58d337287f06f578a92c4a934b7fbaf3aa9
xen, vtd: Fix device check for devices behind PCIe-to-PCI bridges

On some systems, requests devices behind a PCIe-to-PCI bridge all
appear to the IOMMU as though they come from from slot 0, function 0
on that device; so the mapping code much punch a hole for X:0.0 in the
IOMMU for such devices.  When punching the hole, if that device has
already been mapped once, we simply need to check ownership to make
sure it's legal.  To do so, domain_context_mapping_one() will look up
the device for the mapping with pci_get_pdev() and look for the owner.

However, if there is no device in X:0.0, this look up will fail.

Rather than returning -ENODEV in this situation (causing a failure in
mapping the device), try to get the domain ownership from the iommu
context mapping itself.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
xen/drivers/passthrough/vtd/iommu.c